package cn.lingyangwl.agile.misc.statistic.model.rqrs;

import cn.hutool.core.date.LocalDateTimeUtil;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

/**
 * 统计图数据
 * @author shenguangyang
 */
@Data
@Accessors(chain = true)
@NoArgsConstructor
public class ChartData {
    /**
     * 类型, 用于前端进行分组展示统计图, 参考审计日志中的操作日志(分错误/成功)
     */
    private String type;

    private String name;

    private String value;

    public ChartData(String name, String value) {
        this.name = name;
        this.value = value;
    }

    public ChartData(String name, BigDecimal value) {
        this.name = name;
        this.value = value.toPlainString();
    }

    public ChartData(String name, Integer value) {
        this.name = name;
        this.value = String.valueOf(value);
    }

    public ChartData(LocalDate name, Long value) {
        this.name = LocalDateTimeUtil.format(name, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
        this.value = String.valueOf(value);
    }


    public ChartData(LocalDate name, String value) {
        this.name = LocalDateTimeUtil.format(name, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
        this.value = value;
    }

    public ChartData(LocalDate name, BigDecimal value) {
        this.name = LocalDateTimeUtil.format(name, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
        this.value = value.toPlainString();
    }

    public ChartData(LocalDate name, Integer value) {
        this.name = LocalDateTimeUtil.format(name, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
        this.value = String.valueOf(value);
    }
}
